﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SilverlightMessageBoxes
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void InfoButton_Click(object sender, RoutedEventArgs e)
        {
            Message.InfoMessage("Hello! I am here to help you!");
        }

        private void ErrorButton_Click(object sender, RoutedEventArgs e)
        {
            Message.ErrorMessage("Darn! Something went wrong.");
        }

        private void TextInputButton_Click(object sender, RoutedEventArgs e)
        {
            CustomMessage customMessage = new CustomMessage("Please enter the name of your favorite singer?", CustomMessage.MessageType.TextInput);

            customMessage.OKButton.Click += (obj, args) =>
            {
                //Check to see if a user entered text.
                if (customMessage.Input != null)
                    Message.InfoMessage("Thanks for your input: " + customMessage.Input);
                else
                    Message.InfoMessage("No input was received.");
            };


            customMessage.Show();
        }

        private void ComboInputButton_Click(object sender, RoutedEventArgs e)
        {
            String[] comboOptions = new String[] {"Boston Celtics", "L.A. Lakers", "Chicago Bulls", "Philadelphia 76ers"};

            CustomMessage customMessage = new CustomMessage("Please choose your favorite basketball team.", 
                                                             CustomMessage.MessageType.ComboInput, 
                                                             comboOptions);

            customMessage.OKButton.Click += (obj, args) =>
            {
                //Check to see that an option was selected.
                if(customMessage.Input  != null)

                    //Display the selected message.
                    Message.InfoMessage("Go " + customMessage.Input + "!");

                else
                    Message.InfoMessage("No input was received.");
            };


            customMessage.Show();
        }

        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            
            CustomMessage customMessage = new CustomMessage("Do you like me?", CustomMessage.MessageType.Confirm);
            
            customMessage.OKButton.Click += (obj, args) =>
            {
                Message.InfoMessage("Thanks. You make me blush.");
            };

            customMessage.CancelButton.Click += (obj, args) =>
            {
                Message.ErrorMessage("Wrong answer! Your computer will distruct in 10 seconds...");
            };


            customMessage.Show();
        }
    }
}
